/**
 * kiem tra từ thuê bao tới thuê bao có thuộc cùng một dải số 
 * va toi thua bao >= tu thue bao hay không
 */
package com.fis.vaadin.validator;

import com.vaadin.data.validator.AbstractValidator;
import com.vaadin.ui.TextField;

public class CompareNumberValidator extends AbstractValidator
{
	private TextField txtFromNumber;
	
	public TextField getTxtFromNumber()
	{
		return txtFromNumber;
	}
	
	public void setTxtFromNumber(TextField txtFromNumber)
	{
		this.txtFromNumber = txtFromNumber;
	}
	
	public CompareNumberValidator(String errorMessage, TextField txtFromNumber)
	{
		super(errorMessage);
		this.setTxtFromNumber(txtFromNumber);
	}
	
	@Override
	public boolean isValid(Object value)
	{
		Long toNumber, fromNumber;
		toNumber = Long.parseLong(value.toString().trim());
		fromNumber = Long.parseLong(txtFromNumber.getValue().toString().trim());
		
		return (fromNumber <= toNumber);
	}
	
}
